package 力扣._2048_下一个更大的数值平衡树;

class Solution2 {

    public int nextBeautifulNumber(int n) {
        for (int i = 1; ; i++) {
            int[] cnt = new int[10];
            int t = i;
            while (t > 0) {
                cnt[t % 10]++;
                t /= 10;
            }
            int j=0;
            for ( ; j < cnt.length; j++) {
                if(cnt[j]!=j && cnt[j]!=0)
                    break;
            }
            if(j==cnt.length) {
                System.out.println(i);
                if (i > n)
                    return i;
            }
        }
    }

    public static void main(String[] args) {
        Solution2 s = new Solution2();
        System.out.println(s.nextBeautifulNumber(1000000));
    }

}